#include<stdio.h>

double mysqrt(double y)
{
  double start = 0, end = y;
  int key = 1;
  double x;
  while (key)
  {
    x = (start + end) / 2;
    if (y - x * x >= 0.001)
    {
      start = x;
    }
    else if (x * x - y >= 0.001)
    {
      end = x; 
    }
    else{
      key = 0;
    }
  }

  return x;
}


int main()
{
  printf("%f\n", mysqrt(2));
  return 0;
}
